{template 'common/header'}
<ul class="nav nav-tabs">
	<li class="active"><a href="{php echo $this->createWebUrl('user');}">商品列表</a></li>
	<li><a href="{php echo $this->createWebUrl('user_add',array('op' => 'post'));}">添加商品</a></li>
</ul>
<div class="main">

	<div class="panel panel-default">
		<div class="panel-heading">商品列表</div>
		<div class="panel-body">
			<div class="table-responsive panel-body">
				<table class="table table-hover" style="min-width: 300px;">
					<thead class="navbar-inner">
						<tr>
							<th class="col-sm-2">id</th>
							<th class="col-sm-2">姓名</th>
							<th class="col-sm-2">手机号</th>
							<th class="col-sm-2 text-right">操作</th>
						</tr>
					</thead>
					<tbody>
						{loop $array $key $vo}
						<tr>
							<td>{$vo['id']}</td>
							<td>{$vo['name']}</td>
							<td>{$vo['phone']}</td>
							<td class="text-right">
								<a href="{php echo $this->createWebUrl('user_edit', array('id'=>$vo['id']));}" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="" data-original-title="编辑"><i class="fa fa-pencil"></i></a>
								<a onclick="if(!confirm('删除后将不可恢复,确定删除吗?')) return false;" href="{php echo $this->createWebUrl('user_del', array('id'=>$vo['id']));}" class="btn btn-default btn-danger" data-toggle="tooltip" data-placement="top" title="" data-original-title="删除"><i class="fa fa-times"></i> </a>
							</td>
						</tr>
						{/loop}
						{if $data == ''}
						<tr>
							<td colspan="8">
								尚未添加商品
							</td>
						</tr>
						{/if}
					</tbody>
				</table>
				{$pager}
			</div>
		</div>
	</div>
</div>
<script>
	window.onload = function (e) {
		var code = "";
		var lastTime, nextTime;
		var lastCode, nextCode;

		document.onkeypress = function (e) {
			nextCode = e.which;
			nextTime = new Date().getTime();

			if (lastCode != null && lastTime != null && nextTime - lastTime <= 30) {
				code += String.fromCharCode(lastCode);
			} else if (lastCode != null && lastTime != null && nextTime - lastTime > 100) {
				code = "";
			}

			lastCode = nextCode;
			lastTime = nextTime;
		}

		this.onkeypress = function (e) {
			if (e.which == 13) {
				
				var nowDate = new Date();
				var str_time = nowDate.getTime(); //转换成时间戳
			
				$.ajax({
					type: "get",
					
					url: "http://api.juheapi.com/jhbar/bar",
					data:{
						appkey:'8425da080c201b4086150e29cf1b42ab',
						cityid:1,
						barcode:'6923450605332',
						pkg:'条码查询',
					},
					dataType:"jsonp",
					success: function (data) {
					
						console.log(data);
					},

				})
				
				$('.isbn13').val(code)
			}
		}
	}

</script>
{template 'common/footer'}